<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        
        var arr = [1, 2, 3, 4, 5, 6, 71, 8, 9, 10];

        function max(arr) {
            var end={};
            var max = arr[0];
            var min = arr[0];
            //遍历数组
            for (var i = 1; i < arr.length; i++) {
                if (arr[i] > max) { 
                    max = arr[i];
                }

                if (arr[i] < min) {
                    min = arr[i];
                }
                end[0]=max;
                end[1]=min;  
            }
            return end;
        }
        
        console.log("最大值："+max(arr)[0]);
        console.log("最小值："+max(arr)[1]);
        console.log("最大值："+end[1]);
    </script>
</body>

</html>